home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / share / ewl / examples / ewl_button_test.c < prev    next >
C/C++ Source or Header  |  2006-01-09  |  4KB  |  138 lines

  1. #include "ewl_test.h"
  2.  
  3. static Ewl_Widget *button_button = NULL;
  4.  
  5. static void
  6. __delete_button_test_window(Ewl_Widget *w, void *ev_data __UNUSED__, 
  7.                     void *user_data __UNUSED__)
  8. {
  9.     ewl_widget_destroy(w);
  10.  
  11.     ewl_callback_append(button_button, EWL_CALLBACK_CLICKED,
  12.                 __create_button_test_window, NULL);
  13. }
  14.  
  15. void
  16. __create_button_test_window(Ewl_Widget *w, void *ev_data __UNUSED__, 
  17.                         void *user_data __UNUSED__)
  18. {
  19.     Ewl_Widget *button_win;
  20.     Ewl_Widget *button_box;
  21.     Ewl_Widget *separator[2];
  22.     Ewl_Widget *button[2];
  23.     Ewl_Widget *check_button[3];
  24.     Ewl_Widget *radio_button[2];
  25.     Ewl_Widget *label;
  26.  
  27.     button_button = w;
  28.  
  29.     button_win = ewl_window_new();
  30.     ewl_window_title_set(EWL_WINDOW(button_win), "Button Type Test");
  31.     ewl_window_name_set(EWL_WINDOW(button_win), "EWL Test Application");
  32.     ewl_window_class_set(EWL_WINDOW(button_win), "EFL Test Application");
  33.  
  34.     if (w) {
  35.         ewl_callback_del(w, EWL_CALLBACK_CLICKED,
  36.                     __create_button_test_window);
  37.         ewl_callback_append(button_win, EWL_CALLBACK_DELETE_WINDOW,
  38.                     __delete_button_test_window, NULL);
  39.     } else 
  40.         ewl_callback_append(button_win, EWL_CALLBACK_DELETE_WINDOW,
  41.                     __close_main_window, NULL);
  42.     ewl_widget_show(button_win);
  43.  
  44.     /*
  45.      * Create the main box for holding the button widgets
  46.      */
  47.     button_box = ewl_vbox_new();
  48.     ewl_container_child_append(EWL_CONTAINER(button_win), button_box);
  49.     ewl_box_spacing_set(EWL_BOX(button_box), 10);
  50.     ewl_widget_show(button_box);
  51.  
  52.     /*
  53.      * Create a button to be displayed witha label.
  54.      */
  55.     button[0] = ewl_button_new();
  56.     ewl_button_label_set(EWL_BUTTON(button[0]), "With Label");
  57.     ewl_container_child_append(EWL_CONTAINER(button_box), button[0]);
  58.     ewl_object_alignment_set(EWL_OBJECT(button[0]), EWL_FLAG_ALIGN_LEFT);
  59.     ewl_widget_show(button[0]);
  60.  
  61.     /*
  62.      * Create a button that does not contain a label
  63.      */
  64.     button[1] = ewl_button_new();
  65.     ewl_container_child_append(EWL_CONTAINER(button_box), button[1]);
  66.     ewl_object_alignment_set(EWL_OBJECT(button[1]), EWL_FLAG_ALIGN_LEFT);
  67.     ewl_widget_show(button[1]);
  68.  
  69.     /*
  70.      * Add a separator between the classic buttons and the check buttons.
  71.      */
  72.     separator[0] = ewl_hseparator_new();
  73.     ewl_container_child_append(EWL_CONTAINER(button_box), separator[0]);
  74.     ewl_widget_show(separator[0]);
  75.  
  76.     /*
  77.      * Create a check button with a label.
  78.      */
  79.     check_button[0]  = ewl_checkbutton_new();
  80.     ewl_button_label_set(EWL_BUTTON(check_button[0] ), "With Label");
  81.     ewl_container_child_append(EWL_CONTAINER(button_box), check_button[0]);
  82.     ewl_object_alignment_set(EWL_OBJECT(check_button[0]),
  83.                  EWL_FLAG_ALIGN_LEFT);
  84.     ewl_widget_show(check_button[0]);
  85.  
  86.     /*
  87.      * Create a check button with a label and checked.
  88.      */
  89.     check_button[1]  = ewl_checkbutton_new();
  90.     ewl_button_label_set(EWL_BUTTON(check_button[1] ), "With Label and checked");
  91.     ewl_checkbutton_checked_set(check_button[1], TRUE);
  92.     ewl_container_child_append(EWL_CONTAINER(button_box), check_button[1]);
  93.     ewl_object_alignment_set(EWL_OBJECT(check_button[1]),
  94.                  EWL_FLAG_ALIGN_LEFT);
  95.     ewl_widget_show(check_button[1]);
  96.  
  97.     /*
  98.      * Create a check button w/o a label.
  99.      */
  100.     check_button[2]  = ewl_checkbutton_new();
  101.     ewl_container_child_append(EWL_CONTAINER(button_box), check_button[2]);
  102.     ewl_object_alignment_set(EWL_OBJECT(check_button[2]),
  103.                  EWL_FLAG_ALIGN_LEFT);
  104.     ewl_widget_show(check_button[2]);
  105.  
  106.     /*
  107.      * Add a separator between the check buttons and the radio buttons
  108.      */
  109.     separator[1] = ewl_hseparator_new();
  110.     ewl_container_child_append(EWL_CONTAINER(button_box), separator[1]);
  111.     ewl_widget_show(separator[1]);
  112.  
  113.     /*
  114.      * Add a radio button with
  115.      */
  116.     radio_button[0]  = ewl_radiobutton_new();
  117.     ewl_button_label_set(EWL_BUTTON(radio_button[0] ), "With Label");
  118.     ewl_radiobutton_checked_set(radio_button[0], TRUE);
  119.     ewl_container_child_append(EWL_CONTAINER(button_box), radio_button[0]);
  120.     ewl_object_alignment_set(EWL_OBJECT(radio_button[0]),
  121.                  EWL_FLAG_ALIGN_LEFT);
  122.     ewl_widget_show(radio_button[0]);
  123.  
  124.     radio_button[1]  = ewl_radiobutton_new();
  125.     ewl_radiobutton_chain_set(EWL_RADIOBUTTON(radio_button[1]), 
  126.                               EWL_RADIOBUTTON(radio_button[0]));
  127.     ewl_container_child_append(EWL_CONTAINER(button_box), radio_button[1]);
  128.     ewl_object_alignment_set(EWL_OBJECT(radio_button[1]),
  129.                  EWL_FLAG_ALIGN_LEFT);
  130.     ewl_widget_show(radio_button[1]);
  131.  
  132.     label = ewl_label_new();
  133.     ewl_label_text_set(EWL_LABEL(label), "A label");
  134.     ewl_container_child_append(EWL_CONTAINER(button_box), label);
  135.     ewl_widget_show(label);
  136. }
  137.  
  138.